<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
function cu($url, $post_data=''){
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
  curl_setopt($ch, CURLOPT_HEADER, false);
  if($post_data!=''){
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  }
  $output = curl_exec($ch);
  curl_close($ch);

  return $output;
}
/**
 * 推送给socket
 * @wyy.xb@qq.com xiaobai
 * @param         [type]  $event [description]
 * @param         [type]  $user  [description]
 * @param         [type]  $info  [description]
 * @return        [type]         [description]
 */
function pushSocket($event,$info,$user=""){
  $post=[
    "uid"=>$user,
    "event"=>$event,
    "info"=>$info
  ];
  $R=cu(config('socket_url')."/post" , $post );
  if($R=="ok"){
    return true;
  }
  return false;
}
